package com.frostmourne.loreoriginex.listeners;

import com.frostmourne.loreoriginex.api.events.AttributeUpdateEvent;
import com.frostmourne.loreoriginex.objects.EntityData;
import com.frostmourne.loreoriginex.objects.loreorigins.LoreOriginAttack;
import com.frostmourne.loreoriginex.objects.managers.PlayerDataManager;
import com.frostmourne.loreoriginex.utils.TaskUtils;
import com.gitee.mxstars.events.ArmourChangeEvent;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.ItemStack;

public class PlayerListener implements Listener {

    @EventHandler
    public void changeArmours(InventoryCloseEvent e){

        EntityData entityData = new EntityData(e.getPlayer());
        PlayerDataManager.getDataMap().put(e.getPlayer().getUniqueId(),entityData);
        entityData.tryUpdate();

    }

    @EventHandler
    public void attack(EntityDamageByEntityEvent e){

        double damage = TaskUtils.loreOriginAttack.getDamage((LivingEntity) e.getDamager(), (LivingEntity) e.getEntity());

        e.setDamage(damage);


    }


}
